<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>最佳女王瑜伽培训</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />

    <style>      
        body {
            margin: 0px;
            padding: 0px;
        }
        .titleContent{
            padding: 10px 0px;
            background-color: rgba(0,0,0,1);
            border-bottom: 0px solid #ddd;
            margin: 0px;
            position: fixed;
            top: 0px;
            width: 100%;
            min-height:18px;
        }
        #title {
            background-image: url(../images/back.png);
            background-repeat: no-repeat;
            color: #fff;
            font-size: 16px;
            text-align: center;
            font-weight: bold;
            height:18px;
        }

        #content {
            overflow: hidden;
            padding: 2px;
            margin-top: 40px;
            min-height:150px;
        }

       

        .item {
            border-bottom: 1px solid #eee;
            padding: 5px 0px;
            padding-left:10px;
            height: 50px;
            overflow: hidden;
        }

        .leftContent {
            width: 50px;
            height: 50px;
            border: 0px solid #eee;
            overflow: hidden;
            float: left; 
             display: table-cell;
             vertical-align:middle;
        }

            .leftContent img {
                width: 50px;
                vertical-align:middle;
            }

        .rightContent {
            display: inline-block;
            width: -webkit-calc(100% - 72px);
            width: -moz-calc(100% - 72px);
            width: calc(100% - 72px);
            margin-left: 10px;
        }

            .rightContent .title {
                line-height: 24px;
                font-size: 16px;
                color: #666;
                height: 28px;
                overflow: hidden;

            }

            .rightContent .date {
                color: #999;
                font-size: 12px;
                text-align: left;
                padding-right: 5px;
				margin-top:7px;
            }
            .msg{ text-align:center;color:#888;font-size:12px;padding:5px;display:none;}
            .more{
                text-align:center;
                padding:10px;
                color:#ff0000;
                border:0px solid #eee;
                margin-top:5px;
            }
    </style>
</head>
<body>

    <div class="loading" style="background-color: rgba(255, 255, 255, 0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1000; background-image: url(&quot;&quot;); background-position: center center; background-repeat: no-repeat; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-size: 50px;"></div>
    <div class="titleContent" onclick="window.history.back();">
        <div id="title">
            新闻动态
        </div>
    </div>
    
    <div id="content">
        <div id="newContent" style="display:none;">

        </div>
        <div class="msg">加载中……</div>
        <div class="more" style="display:none;">显示更多>></div>
    </div>

    <script src="/js/lib/jquery.js"></script>
    <script type="text/javascript">
        var pageIndex = 0;
        var busy = 0;
        function getnewsList() {
            if (busy == 2) return;
            busy = 1;
            var Jsondata = {};
            Jsondata.type = "新闻动态";
            pageIndex++;
            Jsondata.pageIndex = pageIndex;
            Jsondata.pageSize = 5;
            Jsondata.sort = "createDate";
            Jsondata.asc = -1;
            $(".more").hide();
            $.post('/admin/getnewsListByType', JSON.stringify(Jsondata), function (response) {
                if (response.length == 0) {				   
                    busy = 2;
                    return;
                }
                $(".msg").show();
                var template = '<a href="{{url}}" target="_blank" style="display:block;"><div class="item">'
                    + '<div class="divInlne leftContent">'
                    + '<img src="../files/upload/xsmall/{{image}}" class="iconImg" />'
                    + '</div>'
                    + '<div class="divInlne rightContent">'
                    + '<div class="title">{{title}}</div>          '
                    + '<div class="date">{{date}}</div>          '
                    + ' </div>'
                    + '</div> </a>';
                console.log(response);
                var resultHTML = "";
                for (i = 0; i < response.length; i++) {
                    var o = response[i];
                    var tempHtml = template;
                    tempHtml = tempHtml.replace("{{url}}", "ContentInfo?id=" + o._id);
                    tempHtml = tempHtml.replace("{{image}}", o.newImg);
                    tempHtml = tempHtml.replace("{{title}}", o.title);
                    tempHtml = tempHtml.replace("{{date}}", getDate(o.createDate));
                    resultHTML += tempHtml;
                }
				
                $("#newContent").append(resultHTML);
				$(".msg").hide();
                $(".more").show();
				if(pageIndex==1){
                   $("#newContent").show();
				  setTimeout(function () {                     				
                    $(".loading").hide(); 										
                    }, 1000); 
				}
			                  
                
                busy = 0;

                $(".iconImg").load(function () {
                    var margin_top = $(this).height() >= 50 ? "0px" : (25 - $(this).height() / 2).toString() + "px";                    
                    $(this).css("margin-top", margin_top);
                });               
            })
        }

        function getDate(value) {
            return (value.substring(0, 11).replace("T", "日").replace("-", "年").replace("-", "月").substring(5,11));
        }
        $(function () {
            $('.page-loading').delay(0).fadeOut(1000);
            getnewsList();

            $(".more").click(function () { getnewsList();});
            $(window).bind("scroll", function (e) {
                var ScrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
                if (busy == 2) return;
                if (ScrollBottom < 100) {
                    if (busy == 1) return;
                    getnewsList();
                }
            })
        });
    </script>

</body>

</html>
